﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HRM.DAL.DAO;
using HRM.DAL.Gateway;

namespace HRM.BLL
{
    public class MessageManager
    {
        MessageGateway gateway=new MessageGateway();
        public bool SendMessage(Message message)
        {
            EmployeeManager employeeManager=new EmployeeManager();
            int id = employeeManager.GetEmployeeID(message.Recever);
            string reciver = employeeManager.GetEmployeeName(id);
            message.ReceverName = reciver;
            return gateway.SendMessage(message);
        }
        public List<Message> ReatriveMessages(Code code)
        {
            return gateway.ReatriveMessages(code);
        }

        public Message ReadMessage(int messageId)
        {
            gateway.ChangeFlag(messageId);
            return gateway.ReadMessage(messageId);
        }
        public bool DeleteMessage(int messageId)
        {
            return gateway.DeleteMessage(messageId);
        }
        public int CountUnRead(Code code)
        {
            return gateway.CountUnRead(code);
        }
    }
}